<?php 
defined('IN_TS') or die('Access Denied.');

$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$my = isset($_GET['my']);

if(!$TS_USER['userid']){
    $TS_USER['userid']=0;
}

$arr = 'isaudit=0 and (status<2 or (status=2 and userid='.$TS_USER['userid'].'))';
if($my==1){
    $arr= 'isaudit=0 and  userid='.$TS_USER['userid'];
}

$lstart = $page*12-12;

$url = tsUrl('gift','index',array('page'=>''));

//全部商品
$arrGift = $new['gift']->findAll('gift',$arr,'isrecommend desc,status asc,addtime desc',null,$lstart.',12');

foreach($arrGift as $k=>$item){
    switch($item['status']){
        case '2':
            $arrGift[$k]['status1'] = '下架';
            break;
        case '0':
            $arrGift[$k]['status1'] = '待售';
            break;
        case '1':
            $arrGift[$k]['status1'] = '售磬';
            break;
    }
}

$giftNum = $new['gift']->findCount('gift',$arr);

$pageUrl = pagination($giftNum, 12, $page, $url);

$title = '微铺';
include template("index");